<?php
/********************************************************
 *
 * 此文件的作用:
 *		后台控制器
 *
 * @copyright Copyright (c) 2008-2009
 * @author 刘昌功 lcg635@126.com
 *
 ********************************************************/
defined('APP_DIR') or die('404 Not Found');

FLEA::loadClass('Common_Action');

class Controller_Teacher extends Common_Action {
	function __construct($ctlName) {
		parent::__construct($ctlName);
		$this->tplDir = TPL_F;
		$this->checkLogined();
	}

	function index() {}
	
	function register() {
		$_modTeacher = FLEA::getSingleton('Model_Teacher');
		if ( $this->_isPOST() ) {
			$result = $_modTeacher->register($_POST, $this->user['userid']);
			js_alert('操作成功', null, url());
		} else {
			$_modUser = FLEA::getSingleton('Model_User');
			$userData = $_modUser->getUserInfo($this->user['userid']);
			$teacherData = $_modTeacher->getInfo($this->user['userid']);
			$viewData = array(
				'form' => $_modTeacher->getForm('register', $teacherData),
				'user' => $userData
			);
			$this->_out('teacher/register', $viewData);
		}
	}
	
}